package com.example.group_20.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: 栋
 * @data: 2023/8/13
 * @descriptions:
 */
public class Result implements ResultCode{
    private Boolean sucess;
    private Integer code;
    private String message;
    private Map<String,Object> data=new HashMap<>();


    public Boolean getSucess() {
        return sucess;
    }

    public void setSucess(Boolean sucess) {
        this.sucess = sucess;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    private Result(){}

    /**
     * @description 成功静态方法
     * @author
     * @return Result
     */
    public static Result Ok(){
        Result r=new Result();
        r.setSucess(true);
        r.setCode(ResultCode.SUCCESS);
        r.setMessage("成功");
        return r;
    }

    public static Result Error(){
        Result r=new Result();
        r.setSucess(false);
        r.setCode(ResultCode.ERROR);
        r.setMessage("失败");
        return r;
    }

    public Result data(String key,Object value){
        this.data.put(key,value);
        return this;
    }

    public Result msg(String msg){
        this.message=msg;
        return this;
    }
}
